package com.csust.travel.common;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptorConfig())
                .addPathPatterns("/**") // 拦截所有的请求路径
                .excludePathPatterns("/login", "/register" ,"/upload/**" ,"/books/upload/**","/email/**","/verify/**","/findPwd"); // 排除登录、注册和刷新Token路径

        WebMvcConfigurer.super.addInterceptors(registry);
    }

    @Bean
    public JwtInterceptor jwtInterceptorConfig() {
        return new JwtInterceptor();
    }
}
